
/*--------------------------------------------------------------*/
/*  Copyright (c) 2006 by the University of Oregon.		*/
/*  See the COPYRIGHT file in this directory for permission	*/
/*  to use and distribute this software.			*/
/*--------------------------------------------------------------*/


// AutoOptionList -- organize and access command line options		

// Nathan Dunn 
// University of Oregon							
// May 2006								
//
// This extends an older version by John Conery and subsequently updated by me.  
//
// Options are explicitly created by the API, but that single creation also handles:
// * parsing the input
// * create help documentation
// * creating xml that is gui parseable
//

#ifndef _AUTOOPTIONLIST_H_
#define _AUTOOPTIONLIST_H_

#include <vector>
using std::vector ;

#include <map>
using std::map ; 

#include <string>
using std::string ; 

#include <list>
using std::list ; 
#include <float.h>

#include "GeneralType.hpp"



class AutoOptionList {
public:
	// previous constructors
  AutoOptionList(int argc, char *argv[]);
  ~AutoOptionList();

	// new methods
	virtual void setBinary(string binaryDescription) ;  // "mpirun app-name"
	virtual string getHelpText() ;  // returns usage+ help
	virtual string getOptionValueText() ;  // returns usage+ help
	virtual string getUsageText() ;   // returns usage+ help
	virtual string getStandardOptionsText() ;  // returns usage+ help
	virtual string getOptionXML() ;  // returns usage+ help
	virtual void standardOptions() ;  // returns usage+ help


	// previous methods (necessary?) 
  int getInt(const string &name, int idefault = 0, int min = -INT_MAX, int max = INT_MAX);
  double getDouble(const string &name, double ddefault = 0.0, double min = -DBL_MAX, double max = DBL_MAX);
  bool getFlag(const string &name, bool bdefault = false);
  string getOption(const string &name, const string &sdefault = "");
  char getChar(const string &name, const char &sdefault = '0');
  void print() const;
  list<string> &contents();
  string next();
  bool empty() const;

	// new methods
protected:
	virtual void initOptions() = 0 ; 
	virtual void parseOption()  ; 
	// could have a generic addVariable, but this allows more flexibility
	virtual void addInt(int* variable,string flag,string shortDescription,int defaultValue=-1, string longDescription="",string group="default" , int order=-1) ;  
	virtual void addDouble(double* variable,string flag,string shortDescription,double defaultValue=-1.0, string longDescription="",string group="default" , int order=-1) ;  
	virtual void addFlag(bool* variable,string flag,string shortDescription,bool defaultValue=false, string longDescription="",string group="default" , int order=-1) ;  
	virtual void addChar(char* variable,string flag,string shortDescription,char defaultValue='a', string longDescription="",string group="default" , int order=-1) ;  
	virtual void addOption(string* variable,string flag,string shortDescription,string defaultValue="a", string longDescription="",string group="default" , int order=-1) ;  


	// non-flag protected methods
	virtual map<string,GeneralType*> getGroupList() ; 
	string mBinaryString ; 
	int mNumArgs; 
  list<string> mInputList;
  list<GeneralType*> mVariableList ;
};


#endif
